<template>
	<div class="sw_system_container">
		<div class="sw_table_container">
			<el-table ref="table" size="medium" :data="data" stripe height="100%" class="index_table_wrapper">
				<el-table-column type="index" label="序号" width="54" align="center"></el-table-column>
				<el-table-column label="实验名称" prop="name" min-width="240"></el-table-column>
				<el-table-column label="申请人" prop="createName" min-width="100"></el-table-column>
				<el-table-column label="操作" width="90" v-if="$isHasAuth(tableButton)">
					<template slot-scope="{ row }">
						<el-button type="text" @click="handleCancelIgnore(row.ignoreId)">删除忽略</el-button>
					</template>
				</el-table-column>
			</el-table>
		</div>
		<slot></slot>
	</div>
</template>

<script>
import { deleteMailIgnore } from '@/api/business/tbMailIgnore';
export default {
	props: {
		data: { type: Array, default: () => [] }
	},
	computed: {
		tableButton() {
			return ['a5ced9d9ed194b2da36c3a6e1667d20f'];
		}
	},
	methods: {
		//管理员 - 取消忽略数据
		handleCancelIgnore(id) {
			let that = this;
			that.$confirm('此操作将删除忽略数据, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning',
				async beforeClose(action, instance, done) {
					if (action === 'confirm') {
						instance.confirmButtonLoading = true;
						await that.deleteIgnoreRequest(id);
						instance.confirmButtonLoading = false;
						done();
					} else {
						done();
					}
				}
			}).catch(() => {});
		},

		//取消忽略请求
		async deleteIgnoreRequest(id) {
			let result = await deleteMailIgnore(id).then((res) => res.data);
			if (result.code === '0') {
				this.$emit('refresh');
				this.$showCustomMessage('success', `取消反馈忽略成功！`);
			}
		}
	}
};
</script>

<style scoped></style>
